/**
 * @name        useLocaleStore.ts
 * @author      shenyc
 * @date        2020-05-06 - ?
 * @copyright   Copy right (c) shenyc (shenyczz@163.com).
 *              All rights reserved.
 *
 ******************************************************************************/
// {{@@@}}
"use strict"
// ----------------------------------------------------------------------------
/**
 * 本地状态存储
 */
import { defineStore } from "pinia"
import { StoreID, persistedStateConfig } from "./common"
// ----------------------------------------------------------------------------
//
const SID = StoreID.LOCALE_STORE
/**
 * 本地状态存储
 * @description 使用 config
 */
export const useLocaleStore = defineStore<string, LocaleState>(SID, {
    state: (): LocaleState => ({
        languageKey: "en",
        languageMaps: [
            {
                lang: "zh-CN",
                name: "简体中文",
                icon: "sunny",
            },
            {
                lang: "en",
                name: "English",
                icon: "edit",
            },
        ],
    }),

    getters: {
        // A getter cannot have the same name as another state property
        getTest: (state) => {
            return state.languageKey
        },
    },

    actions: {
        actTest() {
            return this.$id
        },
    },

    // 可以选择需要存储的键,
    // persist: true,
    persist: persistedStateConfig(SID, ["languageKey"]),
})

export default useLocaleStore
// ----------------------------------------------------------------------------
// {{@@@}}
